bash completion not working on Fedora

2010-06-06 1 min read Bash Fedora Linux

I had bash completion installed and after that I had made huge changes to my bashrc and also installed bashstyle. After this the bash-completion stopped working.

I had to spend a lot of time to figure out that the easiest solution was to source the bash-completion again in the end. 🙂

. /etc/bash_completion

colors in bash -- script to display all the possible colors.

2010-06-06 3 min read Bash Fedora Linux

If you wanted to have colors in the bash output (including the colors in PS1-4), don’t you keep wondering how the color code would look on the terminal. So, I wrote this small script to show the complete color codes. This is how the output would look:

\"Bash

And here is the script:

  <td>
    <div class="text codecolorer">
      #!/bin/bash -<br /> #===============================================================================<br /> #<br /> # &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FILE: &nbsp;colors.sh<br /> #<br /> # &nbsp; &nbsp; &nbsp; &nbsp; USAGE: &nbsp;./colors.sh<br /> #<br /> # &nbsp; DESCRIPTION: &nbsp;Bash colors<br /> #<br /> # &nbsp; &nbsp; &nbsp; OPTIONS: &nbsp;---<br /> # &nbsp;REQUIREMENTS: &nbsp;---<br /> # &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BUGS: &nbsp;---<br /> # &nbsp; &nbsp; &nbsp; &nbsp; NOTES: &nbsp;---<br /> # &nbsp; &nbsp; &nbsp; &nbsp;AUTHOR: &nbsp;Amit Agarwal (AKA), amit.agarwal@amit-agarwal.co.in<br /> # &nbsp; &nbsp; &nbsp; COMPANY: &nbsp;Individual<br /> # &nbsp; &nbsp; &nbsp; VERSION: &nbsp;1.0<br /> # &nbsp; &nbsp; &nbsp; CREATED: &nbsp;09/21/2009 06:12:07 PM IST<br /> # &nbsp; &nbsp; &nbsp;REVISION: &nbsp;---<br /> #===============================================================================<br /> <br /> for c in `seq 0 255`;<br /> do<br /> t=5;<br /> [[ $c -lt 108 ]]&&t=0;<br /> for i in `seq $t 5`;<br /> do<br /> #Display the codes also for easier lookup in terminal<br /> <!--loginview start-->echo $i;${c}<!--loginview end--><br /> echo -e "<a class="zem_slink" title="Path (computing)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Path_%28computing%29">\\</a>\e[0;48;$i;${c}m|| $i:$c `seq -s+0 $(($COLUMNS/2))|tr -d \'[0-9]\'`\\e[0m";<br /> done;<br /> done<br /> <br /> # setup_colors - Adds colors to array CC for global use<br /> # 30 - Black, 31 - Red, 32 - Green, 33 - Yellow, 34 - Blue,<br /> # 35 - Magenta, 36 - Blue/Green, 37 - White,<br /> # 30/42 - Black on Green \'30\\;42\'<br /> <!--loginview start-->function setup_colors(){<br /> declare -a CC;<br /> for i in `seq 0 7`;<br /> do<br /> ii=$(($i+7));<br /> CC[$i]="\\033[1;3${i}m";<br /> CC[$ii]="\\033[0;3${i}m";<br /> done;<br /> CC[15]="\\033[30;42m";<br /> R=$\'\\033[0;00m\';<br /> X=$\'\\033[1;37m\';<br /> export R X;<br /> }<br /> function display_colors(){<br /> for i in $(seq 0 $((${#CC[@]} - 1))); do echo -e "${CC[$i]}[$i]\\n$R"; done<br /> }
    </div>
  </td>
</tr>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
\"Reblog
Enhanced by Zemanta

let a cow tell you your fortune

2010-06-03 1 min read Bash Linux
Here\’s something that I saw on commandlinefu yesterday. That sent me thinking about some command to have the cow file picked randomly 🙂 So, here\’s the original command from the commandlinefu:

let a cow tell you your fortune

    <td>
      <div class="text codecolorer">
        $ fortune | <a class="zem_slink freebase/en/cowsay" title="Cowsay" rel="homepage" href="http://www.nog.net/%7Etony/warez/cowsay.shtml">cowsay</a> -f tux
      </div>
    </td>
  </tr>
</table>

Google\’s RE2 regular expression library

2010-05-30 0 min read Bash
\"Image
Image via CrunchBase

?

<a class="zem_slink freebase/en/google" title="Google" rel="homepage" href="http://google.com">Google has announced the release of its RE2 library under a BSDish license. &#8221;At Google, we use <a class="zem_slink freebase/en/regular_expression" title="Regular expression" rel="wikipedia" href="http://en.wikipedia.org/wiki/Regular_expression">regular expressions as part of the interface to many external and internal systems, including Code Search, <a class="zem_slink freebase/en/sawzall" title="Sawzall (programming language)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Sawzall_%28programming_language%29">Sawzall, and <a class="zem_slink" title="Bigtable" rel="homepage" href="http://labs.google.com/papers/bigtable.html">Bigtable. Those systems process large amounts of <a class="zem_slink freebase/en/data" title="Data" rel="wikipedia" href="http://en.wikipedia.org/wiki/Data">data; exponential <a class="zem_slink freebase/en/runtime" title="Run time (computing)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Run_time_%28computing%29">run time would be a serious problem. On a more practical note, these are <a class="zem_slink freebase/en/thread" title="Thread (computer science)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Thread_%28computer_science%29">multithreaded <a class="zem_slink freebase/en/cplusplus" title="C++" rel="wikipedia" href="http://en.wikipedia.org/wiki/C%2B%2B">C++ programs with fixed-size stacks: the unbounded stack usage in typical regular expression implementations leads to stack overflows and server crashes. To solve both problems, we&#8217;ve built a new regular expression engine, called RE2, which is based on <a class="zem_slink freebase/en/automata_theory" title="Automata theory" rel="wikipedia" href="http://en.wikipedia.org/wiki/Automata_theory">automata theory and guarantees that searches complete in <a class="zem_slink freebase/en/linear_time" title="Linear time" rel="wikipedia" href="http://en.wikipedia.org/wiki/Linear_time">linear time with respect to the size of the input and in a fixed amount of stack space.&#8221; More information can be found on the <a href="http://code.google.com/p/re2/" target="_blank">RE2 project page.<h6 class="zemanta-related-title">Related articles by Zemanta <ul class="zemanta-article-ul"> <li class="zemanta-article-ul-li"><a href="http://glinden.blogspot.com/2010/03/gfs-and-its-evolution.html">GFS and its evolution (glinden.blogspot.com) <li class="zemanta-article-ul-li"><a href="http://research.swtch.com/2010/03/regular-expression-article-3.html">Regular Expression Article #3 (research.swtch.com) <div class="zemanta-pixie"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/456fa268-f416-4aec-ae05-4d1a9c9c2712/"><img class="zemanta-pixie-img" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_b65.png" alt="Reblog this post [with Zemanta]" /><span class="zem-script more-related more-info pretty-attribution paragraph-reblog">

Continue reading

prints line numbers

2010-05-27 1 min read Bash

$ nl

others:
perl -ne &#8217;print &#8221;$. – $_&#8221;&#8217; $1
grep -n . $1
perl -pe &#8217;print &#8221;$. &#8221;&#8217; $1
cat -n $1

  • <a href="http://www.commandlinefu.com/commands/view/4273/prints-line-numbers">View this command to comment, vote or add to favourites
  • <a href="http://feeds2.feedburner.com/commands/by/solarislackware">View all commands by <a href="http://feeds2.feedburner.com/commands/by/solarislackware">solarislackware

<a href="http://www.commandlinefu.com"><img src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/header-logo.jpg" alt="" align="bottom" />

by David Winterbottom (<a href="http://codeinthehole.com">codeinthehole.com)

<a href="http://feedads.g.doubleclick.net/~a/J0FNu7gmMTrQGT61-3dKUYYmlBY/0/da"><img src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~a/J0FNu7gmMTrQGT61-3dKUYYmlBY/0/di" alt="" align="bottom" />
<a href="http://feedads.g.doubleclick.net/~a/J0FNu7gmMTrQGT61-3dKUYYmlBY/1/da"><img src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~a/J0FNu7gmMTrQGT61-3dKUYYmlBY/1/di" alt="" align="bottom" />

<img src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~r/Command-line-fu/~4/L6W6GZj7Dl8" alt="" width="1" height="1" align="bottom" />

Continue reading

Pimp your ls

2010-05-27 1 min read Bash

Here are some of the things that you can do with your ls command.

First off you can use alias&#8217;s to help you type the most typical ls commands. I will give you some examples:

alias ls =&#8221;ls –color –classify&#8221;
alias ls.=&#8221;ls -d .*&#8221;

Very commonly used :

1
  <td>
    <div class="text codecolorer">
      alias ll="ls -lhvrt"<br /> lsd="ls -lUd */" # List directories only
    </div>
  </td>
</tr>
1
2

And after all this you can download the l script from pixelbeat. Quite interesting:

Continue reading

more powerful grep – ack

2010-05-26 2 min read Bash Fedora

For last couple of days, I have been using ack instead of grep. Here is description of ack:

Ack is designed as a replacement for grep.

There are couple of reasons I am using ack. First and foremost being it does not require a filename. So, for seaching amit in all files recursively under the current directory I can simply use

ack amit

More reasons to use ack:

It supports pager option and there can be a rc file that can be used to define the default options that needs to be used with ack. Here is the contents of my $HOME/.ackrc file.

Continue reading
Older posts Newer posts